package com.arithmeticEveryDay.blueBridge;

import java.io.*;
import java.util.StringTokenizer;

/*

6, 3 = 0 3
4, 2 = 0 2
6, 2 = 2 0
8, 4 = 0 4
8, 3 = 2 1
10, 5 = 0 5
10, 4 = 2 4
12, 6 = 0 6
12, 5 = 2 3
12, 4 = 4 0
x + y = k
3x + 2y = c
x = (c - 2(k-y))/3
y = (c - 3(k-x))/2


 */
public class Main {
    static InOut io = new InOut();
    int k, count;
    
    private Main(int k, int count) {
        this.k = k;
        this.count = count;
    }
    private void getNumber() {
        
        if (count % k == 0) {
            
            int temp = count / k;
            if (temp == 3) {
                io.out.println(k + " " + 0);
            } else if (temp == 2) {
                io.out.println(0 + " " + k);
            }
        } else {
            
            int tempCount = count;
            int count1 = 0;
            int count2 = 0;
            while (tempCount > 0) {
                
                tempCount -= 3;
                count1++;
                count2 = tempCount / 2;
                // io.out.println(tempCount + ", " + count1 + ", " + count2);
                if (tempCount % 2 == 0 && count2 + count1 == k) {
                    io.out.println(count1 + " " + count2);
                    break;
                }
            }
        }
    }
    public static void main(String[] args) {
        
        int n = io.nextInt();
        int m = io.nextInt();
        int k = io.nextInt();
        int count = 0;
        for (int i = 0; i < n; i++) {
            String str = io.next();
            for (int j = 0; j < m; j++) {
                if (str.charAt(j) == '1') {
                    count++;
                }
            }
        }
        
        Main main = new Main(k, count);
        main.getNumber();
        io.out.flush();
    }

}
class InOut {
    BufferedReader br;
    StringTokenizer tok;
    PrintWriter out;
    public InOut() {
        br = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(new OutputStreamWriter(System.out)); 
    }
    public boolean hasNext() {
        while (tok == null || !tok.hasMoreElements()) {
            try {
                tok = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                return false;
            }
        }
        return true;
    }
    public String next() {
        if (hasNext()) {
            return tok.nextToken();
        }
        return null;
    }
    public int nextInt() {
        return Integer.parseInt(next());
    }
}
